package com.scsj.supermarket.view.activity.scanmodel;

import android.Manifest;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;


import com.scsj.supermarket.R;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;
import com.vondear.rxtools.RxPermissionsTool;

import cn.bingoogolapple.qrcode.core.QRCodeView;


/**
 * 扫码二维码
 */
public class ScanCodeActivity extends BaseActivity implements View.OnClickListener {

    private QRCodeView mQRCodeView;
    private ImageView scan_his_iv;
    private LinearLayout change_to_edit_ll;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //        //获取动态权限
        RxPermissionsTool.
                with(this).
                addPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE).
                addPermission(Manifest.permission.CAMERA).
                initPermission();
    }

    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_scan);
        initToolbar();
        setToolbarTitle("扫一扫");
        hasWhiteBack(true);
    }

    @Override
    protected void onStart() {
        super.onStart();
        mQRCodeView.startCamera();
//        mQRCodeView.startCamera(Camera.CameraInfo.CAMERA_FACING_FRONT);
        mQRCodeView.showScanRect();
    }

    @Override
    protected void initView() {
        mQRCodeView = findViewById(R.id.qrcode_qv);
//        scan_his_iv = findViewById(R.id.scan_his_iv);
        change_to_edit_ll = findViewById(R.id.change_to_edit_ll);

    }

    @Override
    protected void initListener() {
//        scan_his_iv.setOnClickListener(this);
        change_to_edit_ll.setOnClickListener(this);
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void onStop() {
//        mQRCodeView.stopCamera();
        super.onStop();
    }

    @Override
    protected void onDestroy() {
//        mQRCodeView.onDestroy();
        super.onDestroy();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
//            case R.id.scan_his_iv:
//                startActivity(ScanRecordActivity.class);
//                break;
//            case R.id.change_to_edit_ll:
//                startActivity(EditCodeActivity.class);
//                break;
        }
    }
}
